package com.huike.web.controller.contract;

import com.huike.business.service.ITbBusinessService;
import com.huike.clues.domain.TbAssignRecord;
import com.huike.clues.service.ISysUserService;
import com.huike.clues.service.ITbClueService;
import com.huike.common.core.controller.BaseController;
import com.huike.common.core.domain.AjaxResult;
import com.huike.common.core.page.TableDataInfo;
import com.huike.contract.domain.vo.TransVo;
import com.huike.contract.service.ITbContractService;
import com.huike.contract.service.ITransferService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/transfer")
public class TransferController extends BaseController {
    @Autowired
    ITbBusinessService iTbBusinessService;
    @Autowired
    ITbClueService iTbClueService;
    @Autowired
    ISysUserService iUserService;
    @Autowired
    ITbContractService iTbContractService;
    @Autowired
    ITransferService iTransferService;


    //转派列表查询 分页
    @GetMapping("list")
    public TableDataInfo list(TransVo transVo) {
        //TransVo transVo = new TransVo();
        startPage();
        /*TbBusiness tbBusiness = iTbBusinessService.selectTbBusinessById(sysUser.getUserId());
        TbClue tbClue = iTbClueService.selectTbClueById(sysUser.getUserId());
        String createByclue = tbClue.getCreateBy();
        String createBybusiness = tbBusiness.getCreateBy();
        int numc = iTbClueService.selectTbClueList1(createByclue);
        int numb = iTbBusinessService.selectTbBusinesslist1(createBybusiness);
        List<SysUser> list = iUserService.selectUserlist(sysUser);
        for (SysUser user : list) {
              transVo.setUserId(user.getUserId());
              transVo.setUserName(user.getUserName());
              transVo.setPhonenumber(user.getPhonenumber());
              transVo.setCreateTime(user.getCreateTime());
              transVo.setClueNum(numc);
              transVo.setBusinessNum(numb);
        }*/
        List<TransVo> list=iTbContractService.selectTbContractlist1(transVo);

        return getDataTablePage(list);
    }
        //转派线索/商机
    @PutMapping("assignment/{type}/{userId}/{transferUserId}")
    public AjaxResult assignment(@PathVariable String type,@PathVariable Long userId,@PathVariable Long transferUserId){
        iTransferService.selcetinsetassignment(type,userId,transferUserId);
        return AjaxResult.success("转派成功");
    }
}